from flask import Flask, render_template, request

from platforms import wangyiyun, yinyuetai, bilibili, youtube

app = Flask(__name__)


@app.route('/')
def hello_world():
    return render_template('down.html')


##
@app.route("/down", methods=['POST'])
def downUrl():
    savepath = './videos'
    url = request.form['url']
    clint = request.form['client']
    if clint == '1':
        res = wangyiyun.wangyiyun().get(url, savepath=savepath, app='demo')
    elif clint == '2':
        res = yinyuetai.yinyuetai().get(url, savepath=savepath, app='demo')
    elif clint == '3':
        res = bilibili.bilibili().get(url, savepath=savepath, app='demo')
    else:
        res = youtube.youtube().get(url, savepath=savepath, app='demo')

if __name__ == '__main__':
    app.run()
